
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>redis03 redis基础知识 · Redis</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="<yangxin19970404@163.com>">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="redis04 String数据类型详解.html" />
    
    
    <link rel="prev" href="redis02 redis安装.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="redis01 redis开始.html">
            
                <a href="redis01 redis开始.html">
            
                    
                    redis01 redis开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="redis02 redis安装.html">
            
                <a href="redis02 redis安装.html">
            
                    
                    redis02 redis安装
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4" data-path="redis03 redis基础知识.html">
            
                <a href="redis03 redis基础知识.html">
            
                    
                    redis03 redis基础知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="redis04 String数据类型详解.html">
            
                <a href="redis04 String数据类型详解.html">
            
                    
                    redis04 String数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="redis05 List数据类型详解.html">
            
                <a href="redis05 List数据类型详解.html">
            
                    
                    redis05 List数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="redis06 Set数据类型详解.html">
            
                <a href="redis06 Set数据类型详解.html">
            
                    
                    redis06 Set数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="redis07 Hash数据类型详解.html">
            
                <a href="redis07 Hash数据类型详解.html">
            
                    
                    redis07 Hash数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="redis08 Zset数据类型详解.html">
            
                <a href="redis08 Zset数据类型详解.html">
            
                    
                    redis08 Zset数据类型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="redis09 Geospatial地理位置详解.html">
            
                <a href="redis09 Geospatial地理位置详解.html">
            
                    
                    redis09 Geospatial地理位置详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="redis10 Hyperloglog基数统计详解.html">
            
                <a href="redis10 Hyperloglog基数统计详解.html">
            
                    
                    redis10 Hyperloglog基数统计详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="redis11 Bitmap位图场景详解.html">
            
                <a href="redis11 Bitmap位图场景详解.html">
            
                    
                    redis11 Bitmap位图场景详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="redis12 Redis事务操作.html">
            
                <a href="redis12 Redis事务操作.html">
            
                    
                    redis12 Redis事务操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="redis13 Redis实现乐观锁.html">
            
                <a href="redis13 Redis实现乐观锁.html">
            
                    
                    redis13 Redis实现乐观锁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="redis14 Jedis.html">
            
                <a href="redis14 Jedis.html">
            
                    
                    redis14 Jedis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="redis15 springBoot整合redis.html">
            
                <a href="redis15 springBoot整合redis.html">
            
                    
                    redis15 springBoot整合redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="redis16 RedisUtil.html">
            
                <a href="redis16 RedisUtil.html">
            
                    
                    redis16 RedisUtil
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="redis17 Redis.config详解.html">
            
                <a href="redis17 Redis.config详解.html">
            
                    
                    redis17 Redis.config详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="redis18 Redis持久化RDB.html">
            
                <a href="redis18 Redis持久化RDB.html">
            
                    
                    redis18 Redis持久化RDB
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="redis19 Redis持久化AOF.html">
            
                <a href="redis19 Redis持久化AOF.html">
            
                    
                    redis19 Redis持久化AOF
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="redis20 Redis发布订阅.html">
            
                <a href="redis20 Redis发布订阅.html">
            
                    
                    redis20 Redis发布订阅
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="redis21 Redis主动复制.html">
            
                <a href="redis21 Redis主动复制.html">
            
                    
                    redis21 Redis主动复制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="redis21 Redis哨兵模式.html">
            
                <a href="redis21 Redis哨兵模式.html">
            
                    
                    redis21 Redis哨兵模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="redis22 Redis缓存穿透和雪崩.html">
            
                <a href="redis22 Redis缓存穿透和雪崩.html">
            
                    
                    redis22 Redis缓存穿透和雪崩
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >redis03 redis基础知识</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x57FA;&#x7840;&#x77E5;&#x8BC6;">&#x57FA;&#x7840;&#x77E5;&#x8BC6;</h3>
<blockquote>
<p>redis&#x6709;16&#x4E2A;&#x6570;&#x636E;&#x5E93;,&#x9ED8;&#x8BA4;&#x662F;&#x4F7F;&#x7528;&#x7B2C;0&#x4E2A;</p>
</blockquote>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;select &#x8FDB;&#x884C;&#x5207;&#x6362;</p>
<pre><code class="lang-shell">    127.0.0.1:6379&gt; select 3  # &#x5207;&#x6362;&#x6570;&#x636E;&#x5E93;
    OK
    127.0.0.1:6379[3]&gt; dbsize  # &#x67E5;&#x770B;&#x5927;&#x5C0F;
    (integer) 0
    127.0.0.1:6379[3]&gt; keys *  # &#x67E5;&#x770B;&#x6240;&#x6709;key
    (empty array)
    127.0.0.1:6379[3]&gt; flushdb  # &#x6E05;&#x7A7A;
    OK
    127.0.0.1:6379[3]&gt; flushall  # &#x6E05;&#x7A7A;&#x6240;&#x6709;
    OK
    127.0.0.1:6379[3]&gt;
</code></pre>
<blockquote>
<p>Redis&#x662F;&#x5355;&#x7EBF;&#x7A0B;&#x7684;!</p>
</blockquote>
<p><strong>&#x660E;&#x767D;redis&#x662F;&#x5F88;&#x5FEB;&#x7684;,&#x5B98;&#x65B9;&#x8868;&#x793A;,Redis&#x662F;&#x57FA;&#x4E8E;&#x5185;&#x5B58;&#x64CD;&#x4F5C;,CPU&#x4E0D;&#x662F;Redis&#x6027;&#x80FD;&#x74F6;&#x9888;.Redis&#x7684;&#x74F6;&#x9888;&#x662F;&#x6839;&#x636E;&#x673A;&#x5668;&#x7684;&#x5185;&#x5B58;&#x548C;&#x7F51;&#x7EDC;&#x5E26;&#x5BBD;,&#x65E2;&#x7136;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5355;&#x7EBF;&#x7A0B;&#x6765;&#x5B9E;&#x73B0;,&#x5C31;&#x7528;&#x5355;&#x7EBF;&#x7A0B;&#x4E86;!&#x6240;&#x4EE5;&#x5C31;&#x4F7F;&#x7528;&#x5355;&#x7EBF;&#x7A0B;&#x4E86;</strong></p>
<blockquote>
<p>Redis&#x4E3A;&#x4EC0;&#x4E48;&#x5355;&#x7EBF;&#x7A0B;&#x8FD8;&#x8FD9;&#x4E48;&#x5FEB;?</p>
</blockquote>
<ul>
<li>&#x8BEF;&#x533A;: &#x9AD8;&#x6027;&#x80FD;&#x7684;&#x670D;&#x52A1;&#x5668;&#x4E00;&#x5B9A;&#x662F;&#x591A;&#x7EBF;&#x7A0B;&#x7684;?</li>
<li>&#x8BEF;&#x533A;: &#x591A;&#x7EBF;&#x7A0B;&#x4E00;&#x5B9A;&#x6BD4;&#x5355;&#x7EBF;&#x7A0B;&#x6548;&#x7387;&#x9AD8;
&#x6838;&#x5FC3;: redis&#x662F;&#x5C06;&#x6240;&#x6709;&#x7684;&#x6570;&#x636E;&#x5168;&#x90E8;&#x653E;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x7684;,&#x6240;&#x4EE5;&#x8BF4;&#x4F7F;&#x7528;&#x5355;&#x7EBF;&#x7A0B;&#x7684;&#x6548;&#x7387;&#x5C31;&#x662F;&#x6700;&#x9AD8;&#x7684;,&#x5BF9;&#x4E8E;&#x5185;&#x5B58;&#x7CFB;&#x7EDF;&#x6765;&#x8BF4;,&#x6CA1;&#x6709;&#x50CF;&#x591A;&#x7EBF;&#x7A0B;&#x90A3;&#x6837;&#x4E0A;&#x4E0B;&#x6587;&#x5207;&#x6362;&#x5C31;&#x662F;&#x6548;&#x7387;&#x6700;&#x9AD8;&#x7684;.&#x8FD9;&#x4E2A;&#x5C31;&#x662F;&#x6700;&#x4F73;&#x7684;&#x65B9;&#x6848;.</li>
</ul>
<p><strong>Redis&#x53EF;&#x4EE5;&#x4F5C;&#x4E3A;&#x6570;&#x636E;&#x5E93;,&#x7F13;&#x5B58;&#x548C;&#x6D88;&#x606F;&#x4E2D;&#x95F4;&#x4EF6;MQ</strong></p>
<ul>
<li>exists key  &gt;  &#x5224;&#x65AD;&#x662F;&#x5426;&#x5B58;&#x5728;</li>
<li><strong>expire key 10   &gt;  &#x81EA;&#x52A8;&#x8FC7;&#x671F;&#x65F6;&#x95F4;&#x7684;&#x8BBE;&#x7F6E;</strong></li>
<li>ttl key  &gt;  &#x67E5;&#x770B;&#x5F53;&#x524D;key&#x5269;&#x4F59;&#x65F6;&#x95F4;</li>
<li>type key  &gt;  &#x67E5;&#x770B;key&#x7684;&#x7C7B;&#x578B;</li>
</ul>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210318103712.png" alt=""></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="redis02 redis安装.html" class="navigation navigation-prev " aria-label="Previous page: redis02 redis安装">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="redis04 String数据类型详解.html" class="navigation navigation-next " aria-label="Next page: redis04 String数据类型详解">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"redis03 redis基础知识","level":"1.4","depth":1,"next":{"title":"redis04 String数据类型详解","level":"1.5","depth":1,"path":"redis04 String数据类型详解.md","ref":"redis04 String数据类型详解.md","articles":[]},"previous":{"title":"redis02 redis安装","level":"1.3","depth":1,"path":"redis02 redis安装.md","ref":"redis02 redis安装.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"<yangxin19970404@163.com>","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Redis","language":"zh-hans","gitbook":"3.2.3","description":"Redis > 缓存技术"},"file":{"path":"redis03 redis基础知识.md","mtime":"2021-04-17T07:00:09.689Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T07:48:08.480Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

